<?php
if(isset($_COOKIE['sesion_administrativo']) && isset($_COOKIE['permisos_sesion'])){
	if($_COOKIE['permisos_sesion'] == 1){
		$rut=$_GET['rutid'];
		$idexamen = $_GET['idexamen'];
		$eliminar_graduado = 'no';
		require_once("../Connections/Conexion.php");
		mysql_select_db($database_Conexion, $Conexion);
		
		/********eliminar registro graduacion************/
		$query = "SELECT GRADO FROM examen_tradicional WHERE COD_EXTRADICIONAL = $idexamen";
		$result = mysql_query($query, $Conexion);
		while($row=mysql_fetch_array($result)){
			if($row['GRADO']>=4)
				$eliminar_graduado = 'si';
		}
		
		if(strcmp('/\.([^\.]*$)/i',$eliminar_graduado, 'si')){
			$query = "SELECT NOTA_GRADUACION FROM graduacion WHERE RUT = $rut";	
			$result = mysql_query($query, $Conexion) or die(mysql_error());
				while($row=mysql_fetch_array($result)){
					$query_eliminar_graduacion = "DELETE FROM graduacion WHERE RUT = $rut";
				}			
			mysql_query($query_eliminar_graduacion, $Conexion) or die(mysql_error());	
		
		}
		
		
		/********eliminar registro graduacion ********/
		
		
		//eliminar registro examen tradicional
		$query = "DELETE FROM examen_tradicional WHERE RUT = $rut AND COD_EXTRADICIONAL = $idexamen";
		mysql_query($query, $Conexion) or die(mysql_error());	
		
					
		mysql_close($Conexion);
	}
}
header("Location: http://172.16.110.174/udp/Mantenciones/Mantencion_Registros_Alumnos.php?".$_COOKIE['urlback']);
?>